package com.OneTest;

public class ExceptionTest {
    public void ageTest(int n) throws AgeException {
        if(n<0 || n>100){
            AgeException ex = new AgeException("年龄异常");
            throw ex;
        }
    }
    public void idTest(String strID) throws AgeException {
        if(strID.length()<0 || strID.length()>10){
            AgeException ex = new AgeException("学号异常");
            throw ex;
        }
    }
    public static void main(String[] args) {
           ExceptionTest test = new ExceptionTest();
        try {
            test.ageTest(101);
        } catch (AgeException e) {
            e.printStackTrace();
        }
        try {
            test.idTest("11111111111111111111111111");
        } catch (AgeException e) {
            e.printStackTrace();
        }
    }
}
